﻿using Newtonsoft.Json.Linq;
using System.Net;

namespace scanner_tron_balance
{
    internal class Program
    {
        static WebClient wc = new WebClient();
        static void Main(string[] args)
        {

            var files = System.IO.Directory.GetFiles(args[0]);
            foreach (var file in files)
            {
                var lines = System.IO.File.ReadAllLines(file);
                foreach (var line in lines)
                {
                    var words = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                    if (words.Length == 4 && words[1] == "tron")
                    {
                        var addr = words[0];
                        var result = wc.DownloadString("https://apilist.tronscanapi.com/api/accountv2?address=" + addr);
                        var json = JObject.Parse(result);
                        var b = json["balance"].ToString();
                        if (b == "0")
                            continue;
                        var finalline = line + "  " + b + "\n";
                        Console.Write(finalline);
                        System.IO.File.AppendAllText("out.txt", finalline);
                    }

                }
            }
        }
    }
}